import App from "./App";
import { createSSRApp } from "vue";
import pinia from "@/stores/index.ts";
import uviewPlus from "uview-plus";
import hearbar from "./components/hearbar.vue";
import tabbar from "./components/tabbar.vue";

import { useConfigStore } from "./stores/modules/config.ts";
import { useSocketStore } from "./stores/modules/socket.ts";
const initSize = (app) => {
  const configStore = useConfigStore();
  configStore.setmenuButtonInfo(uni.getMenuButtonBoundingClientRect());
  app.config.globalProperties.configStore = configStore;
};

const showToast = uni.showToast;
uni.showToast = (...args) => {
  showToast({ icon: "none", ...args[0] });
};
export function createApp() {
  const app = createSSRApp(App);
  app.use(pinia);
  app.use(uviewPlus);
  app.component("Hearbar", hearbar);
  app.component("Tabbar", tabbar);
  initSize(app);
  const { start } = useSocketStore();
  start()
  return {
    app,
  };
}
